package com.test.springboot.controller;

import com.test.springboot.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@Controller
public class UserController {
	@Autowired
	private HttpServletRequest request;

	@GetMapping({"/reg.html","/"})
	public String regPage(User user){
		return "reg";
	}
	
	
	@PostMapping("/reg.html")
	public String register(@Valid User user, BindingResult result){
		if(result.hasErrors()){
			return "reg";
		}
		return "login";
	}
	
}
